home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
utils
/
gredarc
/
sample.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-12
|
9KB
|
468 lines
/***********************************************************
SAMPLE.C
March 5, 1993
R. Dobbins
***********************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <bios.h>
#include <dos.h>
#include <string.h>
#include <allcode.h>
#include "vga.h"
static IMAGE_ST *girl_image;
static REPLAY_IMG *girl_curr;
static REPLAY_IMG *girl_first;
static int girl_ix = 0;
static IMAGE_ST *girl2_image;
static REPLAY_IMG *girl2_curr;
static REPLAY_IMG *girl2_first;
static int girl2_ix = 0;
static IMAGE_ST *boy_image;
static REPLAY_IMG *boy_curr;
static REPLAY_IMG *boy_first;
static int boy_ix = 0;
static IMAGE_ST *boy2_image;
static REPLAY_IMG *boy2_curr;
static REPLAY_IMG *boy2_first;
static int boy2_ix = 0;
#define NUMMOVE 120
static int girl_moves[NUMMOVE] = {
M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,
M_UPRIGHT,M_UPRIGHT,M_UPRIGHT,M_UPRIGHT,M_UPRIGHT,
M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,
M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,
M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,
M_DNRIGHT,M_DNRIGHT,M_DNRIGHT,M_DNRIGHT,M_DNRIGHT,
M_DOWN,M_DOWN,M_DOWN,M_DOWN,M_DOWN,
M_DOWN,M_DOWN,M_DOWN,M_DOWN,M_DOWN,
M_DNLEFT,M_DNLEFT,M_DNLEFT,M_DNLEFT,M_DNLEFT,
M_LEFT,M_LEFT,M_LEFT,M_LEFT,M_LEFT,
M_LEFT,M_LEFT,M_LEFT,M_LEFT,M_LEFT,
M_LEFT,M_LEFT,M_L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M_UP,M_UP,M_UP,M_UP,M_UP,
M_UP,M_UP,M_UP,M_UP,M_UP,
M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,
M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,M_RIGHT,
M_DOWN,M_DOWN,M_DOWN,M_DOWN,M_DOWN,
M_DOWN,M_DOWN,M_DOWN,M_DOWN,M_DOWN,
M_LEFT,M_LEFT,M_LEFT,M_LEFT,M_LEFT,
M_LEFT,M_LEFT,M_LEFT,M_LEFT,M_LEFT,
M_UP,M_UP,M_UP,M_UP,M_UP,
M_UP,M_UP,M_UP,M_UP,M_UP};
static void move_girl(void)
{
girl_image->data = girl_curr->image_data;
check_move(girl_image,girl_moves[girl_ix]);
girl_curr = girl_curr->next;
if (girl_curr == NULL)
girl_curr = girl_first;
if (girl_ix+1 < NUMMOVE)
{
girl_ix++;
if (girl_ix == 45)
{
change_level(girl_curr->image_data,girl_image->row,
girl_image->col,girl_image->height,girl_image->width,
girl_image->level,5);
girl_image->level = 5;
}
}
else
{
girl_ix = 0;
change_level(girl_curr->image_data,girl_image->row,
girl_image->col,girl_image->height,girl_image->width,
girl_image->level,1);
girl_image->level = 1;
}
}
static void move_girl2(void)
{
girl2_image->data = girl2_curr->image_data;
check_move(girl2_image,girl_moves[girl2_ix]);
girl2_curr = girl2_curr->next;
if (girl2_curr == NULL)
girl2_curr = girl2_first;
if (girl2_ix+1 < NUMMOVE)
{
girl2_ix++;
if (girl2_ix == 45)
{
change_level(girl2_image->data,girl2_image->row,
girl2_image->col,girl2_image->height,girl2_image->width,
girl2_image->level,6);
girl2_image->level = 6;
}
}
else
{
girl2_ix = 0;
change_level(girl2_image->data,girl2_image->row,
girl2_image->col,girl2_image->height,girl2_image->width,
girl2_image->level,2);
girl2_image->level = 2;
}
}
static void move_boy(void)
{
boy_image->data = boy_curr->image_data;
check_move(boy_image,boy_moves[boy_ix]);
boy_curr = boy_curr->next;
if (boy_curr == NULL)
boy_curr = boy_first;
if (boy_ix+1 < NUMMOVE)
boy_ix++;
else
boy_ix = 0;
}
static void move_boy2(void)
{
boy2_image->data = boy2_curr->image_data;
check_move(boy2_image,boy_moves[boy2_ix]);
boy2_curr = boy2_curr->next;
if (boy2_curr == NULL)
boy2_curr = boy2_first;
if (boy2_ix+1 < NUMMOVE)
boy2_ix++;
else
boy2_ix = 0;
}
#define MUSL 45
NOTE_ST music[MUSL] = {
{5,4,4}, // e
{4,4,4}, // d#
{5,4,4}, // e
{4,4,4}, // d#
{5,4,4}, // e
{12,3,4}, // b
{3,4,4}, // d
{1,4,4}, // c
{10,3,4}, // a
{5,2,4}, // e
{10,2,4}, // a
{1,3,4}, // c
{5,3,4}, // e
{10,3,4}, // a
{12,3,4}, // b
{5,2,4}, // e
{9,2,4}, // g#
{5,3,4}, // e
{9,3,4}, // g#
{12,3,4}, // b
{1,4,4}, // c
{5,2,4}, // e
{10,2,4}, // a
{5,3,4}, // e
/*****************/
{5,4,4}, // e
{4,4,4}, // d#
{5,4,4}, // e
{4,4,4}, // d#
{5,4,4}, // e
{12,3,4}, // b
{3,4,4}, // d
{1,4,4}, // c
{10,3,4}, // a
{5,2,4}, // e
{10,2,4}, // a
{1,3,4}, // c
{5,3,4}, // e
{10,3,4}, // a
{12,3,4}, // b
{5,2,4}, // e
{9,2,4}, // g#
{5,3,4}, // e
{1,4,4}, // c
{12,3,4}, // b
{10,3,8}}; // a
void app_start(int argc, unsigned char *argv[])
{
long nwait;
double fps = 18.00;
int x;
int do_sound = 0;
for (x=1;x<argc;x++)
{
if (!stricmp(argv[x],"/m"))
do_sound = 1;
else if (!strnicmp(argv[x],"/f:",3))
fps = atof(argv[x]+3);
}
if (fps <= 0)
{
tellerr("FPS must be > 0");
return;
}
nwait = (long) (onesec / fps);
load_scrn("stage.ggf");
if (!load_palette("sample.pal",0))
return;
if ((girl_first=load_sequence("girl.ggf")) == NULL)
return;
if ((girl_image=append_image(girl_first->image_data,60,80,
image_header.height,image_header.width,1))==NULL)
{
dealloc_seq(girl_first);
return;
}
girl_curr = girl_first;
girl_image->data = girl_curr->image_data;
if ((girl2_first=load_sequence("girl2.ggf")) == NULL)
return;
if ((girl2_image=append_image(girl2_first->image_data,60,190,
image_header.height,image_header.width,2))==NULL)
{
dealloc_seq(girl2_first);
return;
}
girl2_curr = girl2_first;
girl2_image->data = girl2_curr->image_data;
if ((boy_first=load_sequence("boy.ggf")) == NULL)
{
dealloc_all_images();
dealloc_seq(girl_first);
dealloc_seq(girl2_first);
return;
}
if ((boy_image=append_image(boy_first->image_data,60,113,
image_header.height,image_header.width,3))==NULL)
{
dealloc_all_images();
dealloc_seq(girl_first);
dealloc_seq(girl2_first);
dealloc_seq(boy_first);
return;
}
boy_curr = boy_first;
boy_image->data = boy_curr->image_data;
if ((boy2_first=load_sequence("boy2.ggf")) == NULL)
{
dealloc_all_images();
dealloc_seq(girl_first);
dealloc_seq(girl2_first);
return;
}
if ((boy2_image=append_image(boy2_first->image_data,60,223,
image_header.height,image_header.width,4))==NULL)
{
dealloc_all_images();
dealloc_seq(girl_first);
dealloc_seq(girl2_first);
dealloc_seq(boy_first);
dealloc_seq(boy2_first);
return;
}
boy2_curr = boy2_first;
boy2_image->data = boy2_curr->image_data;
colors_black();
initmask();
if (screen_loaded)
showscrn();
else
{
clrall(0x1);
initscrn();
}
showimage(girl_image->data,girl_image->level,
girl_image->row,girl_image->col,
girl_image->height,girl_image->width);
showimage(boy_image->data,boy_image->level,
boy_image->row,boy_image->col,
boy_image->height,boy_image->width);
showimage(girl2_image->data,girl2_image->level,
girl2_image->row,girl2_image->col,
girl2_image->height,girl2_image->width);
showimage(boy2_image->data,boy2_image->level,
boy2_image->row,boy2_image->col,
boy2_image->height,boy2_image->width);
fade_in();
wait_to((long) onesec);
if (do_sound)
start_music(music,MUSL);
for (;;)
{
if (_bios_keybrd(1))
{
getkey();
if (allcode == K_ESC)
break;
}
move_girl();
move_girl2();
move_boy();
move_boy2();
wait_to(nwait);
}
if (do_sound)
quit_music();
fade_out();
dealloc_all_images();
dealloc_seq(girl_first);
dealloc_seq(girl2_first);
dealloc_seq(boy_first);
dealloc_seq(boy2_first);
}